/*
* VFS_Group 19 - IIIT-B, MTech Program, 1st Semester, Data Management.
* 
* Testing all string operations implemented in StringOperations.c.
*
*/

#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include "./../include/StringOperations.h"
#include "./../include/CustomDataTypes.h"

STRING input1 = "C:\\Program Files\\Sandeep\\File1.txt";
STRING input2 = "\\MyFile.txt";

// Testing "GetFileNestingDepth()"
void Test_GetFileNestingDepth()
{
	int depth;
	
	// Test Case 1:
	depth = GetFileNestingDepth(input1);
	printf("\"GetFileNestingDepth()\" Test case 1 Passed ? %s\n", ((depth == 3) ? "True" : "False"));

	// Test Case 2:
	depth = GetFileNestingDepth(input2);
	printf("\"GetFileNestingDepth()\" Test case 2 Passed ? %s\n", ((depth == 1) ? "True" : "False"));
}

// Testing "GetSplittedPath()"
void Test_GetSplittedPath()
{
	int depth = 0;
	int i = 0;
	int validation = 1;
	STRING expectedSplitPaths[4] = {"C:","Program Files", "Sandeep", "File1.txt"};
		
	// Test Case 1:
	STRINGARRAY splittedPaths = GetSplittedPath(input1, '\\');	
		
	depth = GetFileNestingDepth(input1);
	depth++; //Number of files or folders after splitting is one more than depth.
	
	printf("\"GetSplittedPath()\" Test case 1 Passed ? ");

	for(i = 0; i < depth; i++)
	{
		validation = (validation && (strcmp(expectedSplitPaths[i], splittedPaths[i]) == 0));
	}
	
	printf("%s\n", (validation == 1) ? "True" : "False");
	
	free(splittedPaths);	
}

void main()
{	
	// Test "GetFileNestingDepth()"
	Test_GetFileNestingDepth();
	
	// Test "GetSplittedPath()"
	Test_GetSplittedPath();
	
}
